#pragma once

#include "nef_register_base.h"
#include "catalog.h"



#define NEF_ENTRY_POINT_NAME nef_registration_entry_point
#define NEF_ENTRY_POINT_NAME_S2(n) #n
#define NEF_ENTRY_POINT_NAME_S1(n) NEF_ENTRY_POINT_NAME_S2(n)
#define NEF_ENTRY_POINT_NAME_S NEF_ENTRY_POINT_NAME_S1(NEF_ENTRY_POINT_NAME)

inline void __nef_registration_entry_point(std::vector<nef::IExport::Ptr> &exports)
{
	// Add all of the registered exports
	exports.insert(exports.end(), s_registeredExports.begin(), s_registeredExports.end());
}

#define NEF_ENTRY_POINT_2() extern "C" void NEF_ENTRY_POINT_NAME (std::vector<nef::IExport::Ptr> &exports) { __nef_registration_entry_point(exports); }

struct ExplicitRegister
{
	ExplicitRegister(nef_entry_point_function fn)
	{
		nef::Catalog::GlobalCatalog()->AddEntryPoint(fn);
	}
};

#define NEF_ENTRY_POINT() \
	NEF_ENTRY_POINT_2() \
	ExplicitRegister reg(&NEF_ENTRY_POINT_NAME);